<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title></title>
	<style type="text/css">
		.main {
			width: 315px;
			height: 600px;
			margin: 100px auto;
		}

	</style>

	<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css"
		  integrity="sha384-HSMxcRTRxnN+Bdg0JdbxYKrThecOKuH5zCYotlSAcp1+c8xmyTe9GYg1l9a69psu" crossorigin="anonymous">
	<script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
	<script type="text/javascript" src="vue.js"></script>
	<!-- 引入样式 -->
	<link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
	<!-- 引入组件库 -->
	<script src="https://unpkg.com/element-ui/lib/index.js"></script>

	<style type="text/css">
		#addhaha{
			display: none;
		}
	</style>
</head>
<body>
<div id="app">
	<p>
		<el-divider><i class="el-icon-mobile-phone"></i>商家详情</el-divider>
	</p>
	<div class="main">

		<el-form :model="businessInfo" status-icon :rules="rules" ref="businessInfo" label-width="100px"
				 class="demo-ruleForm">

			<el-form-item label="选择市场" prop="mid" >
				<el-select v-model="businessInfo.mid" placeholder="请选择市场">
					<el-option v-for="(c,i) in marketArr" :label="c.mname" :value="c.id"></el-option>
				</el-select>
			</el-form-item>

			<el-form-item label="店铺名称" prop="sname">
				<el-input style="width: 200px;" v-model="businessInfo.sname"></el-input>
			</el-form-item>

			<el-form-item label="营业类别" prop="cid">
				<el-select v-model="businessInfo.cid" placeholder="请选择营业类别">
					<el-option v-for="(c,i) in categoryArr" :label="c.category" :value="c.id"></el-option>
				</el-select>
			</el-form-item>

			<div style="text-align: center;">
				<button type="button" class="btn btn-success" @click="submitBusiness()">提交</button>
				<button type="button" class="btn btn-primary" id="addhaha" @click="addPic()" >添加证件信息</button>
			</div>
			</el-form>
	</div> <!--main-->
</div><!--app-->
<script>
	var app = new Vue({
		el: "#app",
		data: {
			businessInfo:{},
			marketArr:{},
			categoryArr:{},
			marketArr:[],
			categoryArr:[],
			rules:{
				sname: [
					{ required: true, message: '请输入店铺名称', trigger: 'blur' }
				],
				mid: [
					{ required: true, message: '请选择市场', trigger: 'blur' }
				]
				,cid: [
					{ required: true, message: '请选择营业类别', trigger: 'blur' }
				]
			}
		},
		methods: {
			addPic: function () {
					window.location.href = "/cai/businessIntoTwo.html";
			},
			submitBusiness: function () {
				app.$refs["businessInfo"].validate((valid) => {
					if (valid) {
						$.post("/cai/businessRegister/addStore",app.businessInfo,function (backData) {
							if (backData.code == 1) {
								app.$notify.success({
									title: '温馨提示',
									message: backData.msg,
								});
								document.getElementById("addhaha").style.display="inline";
							} else {
								app.$notify.error({
									title: '温馨提示',
									message: backData.msg,
								});
							}
						});
					}
				});
			}
		}
	});
	$.get("/cai/mar/getMarket",function (backData) {
		app.marketArr=backData.data;
	});
	$.get("/cai/goods/listCategory",function (backData) {
		app.categoryArr=backData.data;
	});


</script>

</body>
</html>
